#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#define MAXN 105000
using namespace std;

struct car_ty{
    int s, v, a;
    int x, y;
};

int T;
int n, m, l, vmax;
int detect[MAXN], cnt[MAXN];
bool vised[MAXN];
vector<int> v[MAXN];
car_ty car[MAXN];

void add(int &overload, int i, int x, int y){
    bool flag = 0;
    cout << i << " " << x << " " << y << endl;
    for(int j = 1; j <= n; ++j){
        if(x <= detect[j] && detect[j] <= y){
            if(flag == 0){
                car[i].x = j;
            }
            car[i].y = j;
            flag = 1;
            v[j].push_back(i);
        }
    }
    if(flag){
        overload++;
    }
}

int main()
{
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);

    //duoce qingkong
    cin >> T;
    while(T--){



        cin >> n >> m >> l >> vmax;

        memset(detect, 0, sizeof(detect));
        memset(cnt, 0, sizeof(cnt));
        memset(vised, 0, sizeof(vised));
        memset(car, 0, sizeof(car));
        for(int i = 1; i <= m; ++i){
            v[i].clear();
        }

        for(int i = 1; i <= n; ++i){
            cin >> car[i].s >> car[i].v >> car[i].a;
        }
        for(int i = 1; i <= m; ++i){
            cin >> detect[i];
        }
        int overspeed = 0;

        for(int i = 1; i <= n; ++i){
            double vnow = car[i].v;
            bool flag = 0;
            int last = car[i].s;
            for(int j = 1; j <= m; ++j){
                if(detect[j] < car[i].s){
                    continue;
                }
                vnow = 2 * car[i].a * (detect[j] - last) + pow(vnow, 2);
                if(vnow < 0){
                    vnow = 0;
                }
                last = detect[j];
                vnow = sqrt(vnow);
                if(vnow > 1.0 * vmax){
                    if(flag == 0){
                        car[i].x = j;
                    }
                    flag = 1;
                    car[i].y = j;
                    v[j].push_back(i);
                }
            }
            if(flag){
                overspeed++;
            }
        }

        for(int i = 1; i <= m; ++i){
            cnt[i] = v[i].size();
            //cout << cnt[i] << " ";
        }
        //cout << endl;
/*
        for(int i = 1; i <= m; ++i){
            cout << i << ": ";
            for(int j = 0; j < v[i].size(); ++j){
                cout << v[i][j] << " ";
            }
            cout << endl;
        }
*/
        int cut = 0, ans = 0;
        while(cut < overspeed){
            int maxnum = 0, pos = 0;
            for(int i = 1; i <= m; ++i){
                if(cnt[i] > maxnum){
                    maxnum = cnt[i];
                    pos = i;
                }
            }
            ans ++;
            //cout << maxnum << " " << pos << endl;

            for(int i = 0; i < v[pos].size(); ++i){
                int now = v[pos][i];
                if(vised[now]){
                    continue;
                }
                vised[now] = 1;
                cut ++;
                for(int j = car[now].x; j <= car[now].y; ++j){
                    cnt[j]--;
                }

                bool flag = 0;
                for(int j = 1; j <= m; ++j){
                    if(cnt[j] > 0){
                        flag = 1;
                    }
                }
                if(!flag){
                    break;
                }

            }

        }

        cout << overspeed << " " << m - ans << endl;
    }


    return 0;
}

